﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Phila.PhilaWebService

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Dim strSql As String
            'strSql = "select top 3 t.*, (select tc.Pax_1 from ptn_TourCost where TourId=t.Id and tc.StartDate <= getdate() and tc.EndDate >= getdate()) as Amount from ptn_Tours t inner join ptn_TourCost tc on tc.TourId=t.Id where(t.IsActive = 1 And t.IsFeatured = 1) order by t.UpdatedOn desc"
            'strSql = "select top 3 t.*, tc.* from ptn_Tours t inner join ptn_TourCost tc on t.Id=tc.TourId where tc.ClientType='b2c'"
            strSql = "select t.*, tc.Pax_1 as Price from dbo.ptn_Tours t inner join dbo.ptn_TourCost tc ON(tc.tourid=t.id) where tc.startdate<=getdate() and tc.enddate>=getdate()"
            Fill_dtList(dlHotDeals, strSql)
            Fill_dtList(dlHotels, "select top 4 *, hc.Name as CatName from ptn_Hotels h inner join ptn_HotelCategory hc on hc.Id=h.CategoryId")
            LatestNews()
            FillIntro()
            FillTestimonials()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub LatestNews()
        Dim strData As New StringBuilder
        Dim txt As Array
        txt = RetriveData("select Id, Title, Description, Date from dbo.ptn_News where IsActive=1 and IsArchive=0", 3)
        If Not txt(0) Is Nothing Then
            strData.Append("<p class=""title""><a href=""News.aspx?id=" & txt(0) & """>" & txt(1) & "</a></p>")
            strData.Append("<p class=""date"">" & DisplayDate(txt(3)) & "</p>")
            strData.Append("<p class=""summary"">" & Mid(txt(2), 1, 300) & "</p>")
            hNews.Visible = True
        Else
            strData.Append("<p class=""message"">No Latest News available</p>")
            hNews.Visible = False
        End If
        ltrNews.Text = strData.ToString
    End Sub

    Private Sub FillIntro()
        Dim txt As Array
        Dim Keywords As New HtmlMeta()
        Dim Desc As New HtmlMeta()
        txt = RetriveData("select Name, Summary, Description, MetaTitle, MetaKeywords, MetaDescription from ptn_Pages where IsActive=1 and Id=8", 5)
        ltrIntro.Text = txt(2) & "<a href='AboutUs.aspx'>Read More...</a>"
        Page.Header.Title = txt(3)
        Keywords.Name = "Keywords"
        Keywords.Content = txt(4)
        Desc.Name = "Description"
        Desc.Content = txt(5)
        Page.Header.Controls.Add(Desc)
        Page.Header.Controls.Add(Keywords)
    End Sub

    Private Sub FillTestimonials()
        Dim strData As New StringBuilder
        Dim txt As Array
        txt = RetriveData("select Id, FromName, Date, Message from ptn_Testimonials where IsActive=1", 3)
        If Not txt(0) Is Nothing Then
            strData.Append("<span class=""quotes top""></span>" & txt(3) & "<span class=""quotes bottom""></span>")
            strData.Append("<div class=""poster clearfix"">" & txt(1) & "</div>")
            hTestimonials.Visible = True
        Else
            strData.Append("<p class=""message"">No Testimonials available</p>")
            hTestimonials.Visible = False
        End If
        ltrTestimonials.Text = strData.ToString
    End Sub
End Class
